$(document).ready(function () {

    $("#header").load("Nav.html #Nav", function () {
        element.init();
        $("#UserMsg").addClass("layui-this");
    });

    $.get("/ShenBlue/imp/User_Msg_Json", function (data) {
        console.log(data);
        $("#user_name").val(data.name);
        $("#user_tel").val(data.telephone);
        $("#user_email").val(data.email);
        $("#user_fullname").val(data.fullname);
    });
});

function modifyUser() {
    const name = $("#user_name").val();
    const tel = $("#user_tel").val();
    const email = $("#user_email").val();
    const full = $("#user_fullname").val();
    if (IsEmpty(name, tel, email, full)) {
        layer.msg("禁止留空", {icon: 5});
        return;
    }
    if (!isTelephone(tel)) {
        layer.msg("请输入正确的手机号格式", {icon: 5});
        return;
    }
    $.post("/ShenBlue/imp/ModifyUser", {mode: 1, name: name, tel: tel, email: email, fullname: full}, function (data) {
        const error = data["error"];
        const msg = data["msg"];
        if (error !== undefined) {
            layer.msg(error, {icon: 5});
            setTimeout("location.reload()", 1500);
            return;
        }
        layer.msg(msg, {icon: 1});
        setTimeout("location.reload()", 1500);
        return;
    });
}